package heap

func LookupMethodInClass(class *Class, name, descriptor string) *Method {
	for c := class; c != nil; c = c.superClass {
		for _, m := range c.methods {
			if m.name == name && m.descriptor == descriptor {
				return m
			}
		}
	}
	return nil
}

func lookupMethodInInterfaces(classes []*Class, name, descriptor string) *Method {
	for _, class := range classes {
		for _, m := range class.methods {
			if m.name == name && m.descriptor == descriptor {
				return m
			}
		}

		method := lookupMethodInInterfaces(class.interfaces, name, descriptor)
		if method != nil {
			return method
		}
	}
	return nil
}
